/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.action;

import com.dao.Usermanager;
import com.entity.Student;
import static com.opensymphony.xwork2.Action.INPUT;
import static com.opensymphony.xwork2.Action.SUCCESS;
import com.opensymphony.xwork2.ActionSupport;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.scene.control.Alert;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.swing.JOptionPane;
import org.apache.struts2.ServletActionContext;

/**
 *
 * @author DELL
 */
public class UpdatePassword  extends ActionSupport{
    
    
    
    
        private String password1;
    private String password2;
   




  

    public String getPassword1() {
        return this.password1;
    }

    public void setPassword1(String password1) {
        this.password1 = password1;
    }

    
    public String getPassword2() {
        return this.password2;
    }

    public void setPassword2(String password2) {
        this.password2 = password2;
    }
    
    
    
    
    public UpdatePassword() {
    }
    
    public String execute() throws Exception {
       
                               HttpServletRequest request;
        request =ServletActionContext.getRequest();
                HttpSession session=request.getSession();
        String sno =(String)session.getAttribute("sno");
         
         Student st1=new Student();
         Student st2=new Student();
         st1=(Student)session.getAttribute("student");
         
          Logger.getLogger(this.getClass().getName()).log(Level.INFO, sno);
         
         st2.setPassword(getPassword1());
         st2.setSno(sno);


               
        if (sno!=null) {
            
            
           
                    Usermanager  user=new Usermanager();
        
             user.updatePassword(st2);
             
             JOptionPane.showMessageDialog(null, "修改密码成功", "消息提示", JOptionPane.YES_NO_CANCEL_OPTION);
             
          
           Logger.getLogger(this.getClass().getName()).log(Level.INFO, "111111111111111");
        
    
       
        return SUCCESS;
        }
        else {
        
        return INPUT;
        }
        
        
    }
    
}
